package com.cheng.example.geektime.designpatterns.j57.writeventbuself;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class Student {

    @Subscribe(color = "red")
    public String toString() {
        return "student";
    }


    public static void main(String[] args) {
        Student student = new Student();
        Method[] methods = student.getClass().getDeclaredMethods();

        for (Method method : methods) {
            Annotation annotation = method.getAnnotation(Subscribe.class);
            Annotation[] annotations = method.getAnnotations();
            Annotation annotation1=method.getDeclaredAnnotation(Override.class);

            if (annotations.length == 0) {
                continue;
            }
            System.out.println(annotations[0].getClass());
        }

    }

}
